﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_Sanpham1_Controls_UC_Xemsanpham : System.Web.UI.UserControl
{
    BUS_Product data = new BUS_Product();
    BUS_GroupProduct group = new BUS_GroupProduct();
    protected void Page_Load(object sender, EventArgs e)
    {
        hplXemsanpham.NavigateUrl = "../Xemsanpham.aspx?id_nsx="+Request.QueryString["id_nsx"]+"&id_sp="+Request.QueryString["id_sp"];
        hplSuasanpham.NavigateUrl = "../Suasanpham.aspx?id_nsx=" + Request.QueryString["id_nsx"] + "&id_sp=" + Request.QueryString["id_sp"];
        if (!IsPostBack)
        {
            
            //string id_nsx = Request.QueryString["id_nsx"].ToString();
            string id_sp = Request.QueryString["id_sp"].ToString();
            var dt = data.Product_Detail(id_sp);
            
            dlLoaiSP.DataSource = group.GroupProduct_GetByAll();
            dlLoaiSP.DataBind();
            lblNSX.Text = dt.Rows[0]["NSX"].ToString();
            txtTenSP.Text = dt.Rows[0]["TenSP"].ToString();
            CKEditorControl1.config.toolbar = new object[] { new object[] { "Bold", "Italic", "-", "NumberedList", "BulletedList", "-", "Link", "Unlink", "-", "About" },
                            new object[] { "Cut", "Copy", "Paste", "PasteText", "PasteFromWord", "-", "Print", "SpellChecker", "Scayt" }, };
            CKEditorControl1.Enabled = false;
            CKEditorControl1.Text = dt.Rows[0]["Chitiet"].ToString();
            txtGia.Text = dt.Rows[0]["Gia"].ToString();
            ImageSP.ImageUrl = dt.Rows[0]["Hinhanh"].ToString();
            bool trangthai = bool.Parse(dt.Rows[0]["Trangthai"].ToString());
            if (trangthai)
            {
                lblTrangthai.Text = "Mở";
            }
            else
            {
                lblTrangthai.Text = "Đóng";
            }
        }
    }
    
    public bool GetGroup(string idGroup)
    {
        string id_sp = Request.QueryString["id_sp"].ToString();
        var dt = data.Product_GetByTop(0, "Id = '" + id_sp + "' and GroupProduct_Id like '%" + idGroup + "%'", ""); if (dt.Rows.Count > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
}